﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using X23.Application.RoleManagement.Dto;
using X23.Application.UserManagement.Dto;
using X23.EFCore.Service;
using X23.Model.Role;
using X23.Model.User;

namespace X23.Application.UserManagement
{
    public interface IUserManagementService : ICRUDService<UserDto, User>
    {
        /// <summary>
        /// 微信登陆
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        Task<UserInfoDto> LoginByWeChat(string code);
        /// <summary>
        /// 获取用户权限
        /// </summary>
        /// <param name="predicate"></param>
        /// <returns></returns>
        Task<List<UserRoleDto>> GetUserRoleList(Expression<Func<UserRole, bool>> predicate);
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<bool> DeleteUserAndUserRole(int userId);

        /// <summary>
        /// 测试
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<string> Test(int userId);

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="userDto"></param>
        /// <returns></returns>
        Task<UserInfoDto> Login(LoginUserDto userDto);

        /// <summary>
        /// 根据用户id获取token
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<UserInfoDto> GetTokenByUserId(int userId);

        /// <summary>
        /// 添加或者修改用户
        /// </summary>
        /// <param name="userDto"></param>
        /// <returns></returns>
        Task<bool> AddOrUpdateUser(UserDto userDto);


        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="oldPassword"></param>
        /// <param name="newPassword"></param>
        /// <returns></returns>
        Task<bool> UpdatePassword(int userId,string oldPassword,string newPassword);
    }
}
